#!/bin/bash
#
#dev:enCEE
#
#vars
#functions
arch_lang()
{
	for(( x = 0; x < 1;))
			do
			case $selection in
				1)
				    arch_key_layout
				;;
				2)
					echo "Please enter your 2 letter language group. EG: en for english!"
					read lang
					arch_lang_locale
				;;
				"H" | "h" | "Help" | "help")
					$sys_scripts_dir/arch_help
				;;
				"Q" | "q" | "Quit" | "quit")
					exit 0
				;;	
				*)
					echo "Invalid Response"
					echo "Please select an option from above"
					read selection
				;;
			esac
		done
}
arch_key_layout()
{
	for(( x = 0; x < 1;))
			do
			case $selection in
				1)
					
				  loadkeys be-latin1
				;;
				2)
					loadkeys br-abnt2
				;;
				3)
					loadkeys cf
				;;
				4) 
					loadkeys ca_multi
				;;
				5)
					loadkeys colemak
				;;
				6)	
					loadkeys croat
				;;
				7)
					loadkeys cz-lat2
				;;
				8)
					loadkeys dvorak
				;;
				9)
					loadkeys fr-latin1
				;;
				10)
					loadkeys de-latin1
				;;
				11)
					loadkeys de-latin-nodeadkeys
				;;
				12)
					loadkeys it
				;;
				13)
					loadkeys lt-baltic
				;;
				14)
					loadkeys no-latin1
				;;
				15)
					loadkeys pl
				;;
				16)
					loadkeys pt-latin9
				;;
				17)
					loadkeys ro_win
				;;
				18)
					loadkeys ru4
				;;
				19)
					loadkeys sg-latin1
				;;
				20)
					loadkeys slovene
				;;
				21)
					loadkeys sv-latin1
				;;
				22)
					loadkeys fr_CH-latin1
				;;
				23)
					loadkeys de_CH-latin1
				;;
				24)
					loadkeys es
				;;
				25)
					loadkeys la-latin1
				;;
				26)
					loadkeys tr_q-latin5
				;;
				27)
					loadkeys ua
				;;
				28)
					loadkeys gb
				;;
				29)
					loadkeys uk
				;;
				30)
					loadkeys us
				;;
				"Back" | "back" | "B" | "b" )
					arch_lang
				;;
				"Help" | "help" | "H" | "h" )
					$sys_scripts_dir/arch_help
				;;
				"Quit" | "quit" | "Q" | "q" )
					exit 0
				;;	
				*)
					echo "Invalid Response"
					echo "Please select an option from above"
					read selection
				;;
			esac
		done
}
arch_lang_locale()
{
	cat /mnt/etc/locale |grep $lang
	if [grep == 0]; then
		read locale
		echo "$locale" >> /mnt/etc/locale
	else
		echo "Language not found!"
		echo "Press 1 to view the language list, re-enter your language"
		echo "Press H to open the help menu or Q to quit and return to the menu"
		read select
		case $select in
			1)
				/mnt/etc/locale
			;;
			"Q" | "q" | "Quit" | "quit")
				$sys_scripts_dir/arch_lang
			;;
			"H" | "h" | "Help" | "help")
				$sys_scripts_dir/arch_help
			;;
			*)
				read lang
				arch_lang_locale
			;;
	fi	
}
arch_key_menu()
{
clear
echo "-------------------------------------------"
echo "-      Archlinux Keyboard Layout          -"
echo "-                                         -"
echo "-        For help type 'Help'             -"
echo "-                                         -"
echo "-      Please select an option below      -"
echo "-------------------------------------------"
echo "-                                         -"
echo "-                                         -"
echo "-1)  Belgian                              -"
echo "-2)  Brazilian Portuguese                 -"
echo "-3)  Canadian French                      -"
echo "-4)  Canadian Multilingual                -"
echo "-5)  Colemak(US)                          -"
echo "-6)  Croatian                             -"
echo "-7)  Czech                                -"
echo "-8)  Dvorak                               -"
echo "-9)  French                               -"
echo "-10) German                               -"
echo "-11) German(no dead keys)                 -"
echo "-12) Italian                              -"
echo "-13) Lithuanian (qwerty)                  -"
echo "-14) Norwegian                            -"
echo "-15) Polish                               -"
echo "-16) Portuguese                           -"
echo "-17) Romanian                             -"
echo "-18) Russian                              -"
echo "-19) Singapore                            -"
echo "-20) Slovene                              -"
echo "-21) Swedish                              -"
echo "-22) Swiss - French                       -"
echo "-23) Swiss - German                       -"
echo "-24) Spanish                              -"
echo "-25) Spanish Latinoamerican               -"
echo "-26) Turkish                              -"
echo "-27) Ukrainian                            -"
echo "-28) United Kingdom (GB)                  -"
echo "-29) United Kingdom (UK)                  -"
echo "-30) United States (Default)              -"
echo "-                                         -"
echo "-[H]elp -Open Help Document               -"
echo "-[B]ack -Return to Arch Languange Config. -"
echo "-[Q]uit -Quit and return to main menu     -"
echo "-------------------------------------------"
echo "What is your selection?"
read selection
arch_key_layout
}
#script
clear
echo "-------------------------------------------"
echo "-      Arch Language Configuration        -"
echo "-                                         -"
echo "-        For help type 'Help'             -"
echo "-                                         -"
echo "-      Please select an option below      -"
echo "-------------------------------------------"
echo "-                                         -"
echo "-                                         -"
echo "-1) Change the keyboard layout            -"
echo "-2) Change the locale                     -"
echo "-                                         -"
echo "-[H]elp -Open Help Document			    -"
echo "-[Q]uit -Quit and return to main menu     -"
echo "-------------------------------------------"
echo "What is your selection?"
arch_lang
#end
